package com.xxxy.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.xxxy.commonResult.CommonResult;
import com.xxxy.commonResult.CommonResultPage;
import com.xxxy.dao.TeachingClassDao;
import com.xxxy.model.TeachingClass;
import com.xxxy.response.TeacherResponse;
import com.xxxy.response.TeachingClassResponse;
import com.xxxy.service.TeachingClassService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author sjh
 * @date 2022/2/2 15:28
 */
@Service
public class TeachingClassServiceImpl extends ServiceImpl<TeachingClassDao, TeachingClass> implements TeachingClassService {

    @Autowired
    TeachingClassDao teachingClassDao;

    @Override
    public CommonResultPage list(Integer page, Integer size, TeachingClass teachingClass){
        PageHelper.startPage(page,size);
        List<TeachingClassResponse> teachingClassList = teachingClassDao.list(teachingClass);
        PageInfo<TeachingClassResponse> pageInfo = new PageInfo<>(teachingClassList);
        CommonResultPage result = new CommonResultPage();
        result.setTotal(pageInfo.getTotal());
        result.setData(pageInfo.getList());
        return result;
    }
}
